#ifndef DES_H
#define DES_H

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;


/*
* @ IP_replacement
* init IP replacement
* use table IP
*/
void IP_replacement(const int src[], int des[]);

/*
* @ PC_1_replacement
* PC_1 replacement
* 64 bits to 56 bits
* use table PC_1
*/
void PC_1_replacement(const int src[], int des[]);

/*
* @ PC_2_replacement
* PC_2 replacement
* 56 bits to 48 bits
* use table PC_2
*/
void PC_2_replacement(const int src[], int des[]);

/*
* @ char_to_bit()
* convert char to 64-bit
* 0..7  for first char
* 8..15 for second char
* ...
*
* pass test
*/
void char_to_bit(const char src[], int des[]);

/*
* @bit_to_char
* convert bit to char
* pass test
*/
void bit_to_char(const int src[], char des[]);

/*
* @cycle_left_shift
* left_shift for subkey
* pass test
*/
void cycle_left_shift(const int src[], int des[], int step);

/*
* @cycle_left_shift
* left_shift for subkey
* pass test
*/
void cycle_left_shift(const int src[], int des[], int step);

/*
* @subkey_generate
* generate subkey from src to subkey
* pass test
*/
void subkey_generate(const int src[], int subkey[][48]);

/*
* @E_extend
* pass test
*/
void E_extend(const int src[], int des[]);

/*
* @S_compress
* use S
* pass test
*/
void S_compress(const int src[], int des[]);

/*
*@ Xor
* Xor array a and b
* pass test
*/
void Xor(int a[], int b[], int len);


/*
*@ P_replacement
* use table P
* pass test
*/
void P_replacement(const int src[], int des[]);

/*
*@ IP_inv
* use table IP_reverse
* pass test
*/
void IP_inv(const int src[], int des[]);

/*
*@ wheel_transformation
* Feistel function
* pass test
*/
void wheel_transformation(int src[], int des[], int subkey[]);

void encode(const char plain_text[], const char password[], int des[]);

void decode(int ciphertext[], const char password[], char des[]);

string des_encode(const char password[], string init_plain_text);

string des_decode(const char password[], string cyphertext);

#endif
